using System;
using System.ComponentModel;

using DevExpress.Xpo;
using DevExpress.Data.Filtering;

using DevExpress.ExpressApp;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Persistent.Validation;

namespace SchoolApps.Module.BusinessObjects
{
    [DefaultClassOptions]
    [System.ComponentModel.DefaultProperty("FullName")]
    public class Pupil : BaseObject
    {
        public Pupil(Session session)
            : base(session)
        {
            // This constructor is used when an object is loaded from a persistent storage.
            // Do not place any code here or place it only when the IsLoading property is false:
            // if (!IsLoading){
            //    It is now OK to place your initialization code here.
            // }
            // or as an alternative, move your initialization code into the AfterConstruction method.
        }
        private SchoolYear year;
        public SchoolYear Year {
            get { return year; }
            set { SetPropertyValue("Year", ref year, value); }
        }
        private MyClass myclass;
        [DataSourceProperty("Year.MyClasses")]
        public MyClass MyClass {
            get { return myclass; }
            set { SetPropertyValue("MyClass", ref myclass, value); }
        }
        private string fullName;
        [RuleRequiredField(DefaultContexts.Save)]
        public string FullName {
            get { return fullName; }
            set { SetPropertyValue("FullName", ref fullName, value); }
        }
        private DateTime birthday;
        public DateTime Birthday {
            get { return birthday; }
            set { SetPropertyValue("Birthday", ref birthday, value); }
        }
        private Gender gender;
        public Gender Gender {
            get { return gender; }
            set { SetPropertyValue("Gender", ref gender, value); }
        }
        private string address;
        public string Address {
            get { return address; }
            set { SetPropertyValue("Address", ref address, value); }
        }
        private string telephone;
        public string Telephone {
            get { return telephone; }
            set { SetPropertyValue("Telephone", ref telephone, value); }
        }
        private string hotline;
        [RuleRequiredField(DefaultContexts.Save)]
        public string Hotline {
            get { return hotline; }
            set { SetPropertyValue("Hotline", ref hotline, value); }
        }
        private string notes;
        [Size(SizeAttribute.Unlimited)]
        public string Notes {
            get { return notes; }
            set { SetPropertyValue("Notes", ref notes, value); }
        }
        //Father
        private string fatherName;
        public string FatherName {
            get { return fatherName; }
            set { SetPropertyValue("FatherName", ref fatherName, value); }
        }
        private string fatherYear;
        public string FatherYear {
            get { return fatherYear; }
            set { SetPropertyValue("FatherYear", ref fatherYear, value); }
        }
        private string fatherJob;
        public string FatherJob {
            get { return fatherJob; }
            set { SetPropertyValue("FatherJob", ref fatherJob, value); }
        }
        private string fatherMobile;
        public string FatherMobile {
            get { return fatherMobile; }
            set { SetPropertyValue("FatherMobile", ref fatherMobile, value); }
        }
        //Mother
        private string motherName;
        public string MotherName {
            get { return motherName; }
            set { SetPropertyValue("MotherName", ref motherName, value); }
        }
        private string motherYear;
        public string MotherYear {
            get { return motherYear; }
            set { SetPropertyValue("MotherYear", ref motherYear, value); }
        }
        private string motherJob;
        public string MotherJob {
            get { return motherJob; }
            set { SetPropertyValue("MotherJob", ref motherJob, value); }
        }
        private string motherMobile;
        public string MotherMobile {
            get { return motherMobile; }
            set { SetPropertyValue("MotherMobile", ref motherMobile, value); }
        }
        //Mark.
        [Association("Pupil-Marks")]
        public XPCollection<Mark> Marks {
            get { return GetCollection<Mark>("Marks");}
        }
        public override void AfterConstruction()
        {
            base.AfterConstruction();
            // Place here your initialization code.
        }
    }
    public enum Gender { 
        Male,
        Female
    }
    

}
